<?php
include_once "header.php";
include_once "navbar.php";

$alert = $_GET["alert"];
$nombre = $_GET["nombre"];
$organizacion = $_GET["organizacion"];
$email = $_GET["email"];

switch($alert) {
	case 1 :
		$alert = "Error, el email ya está siendo utilizado";
		break;
	case 2 :
		$alert = "Debe llenar todos los campos obligatorios";
		break;
	case 3 :
		$alert = "El reCAPTCHA no se introdujo correctamente. Vuelva a intentarlo.";
		break;
	case 4 :
		$alert = "Formato del email no válido";
		break;
	case 5 :
		$alert = "Las contraseñas no coinciden";
		break;
		}
?>


<!DOCTYPE html>
  <html>
  <head>
    <title>Huelgas Manifestaciones - Registro</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <link rel='stylesheet' href='./bootstrap/css/bootstrap.css' type='text/css' />
    <link rel='stylesheet' href='./bootstrap/css/bootstrap-responsive.css' type='text/css' />
    <link rel="stylesheet" href="./css/map.css" type="text/css" />
    <link rel="stylesheet" href="./css/mobile.css" type="text/css" media="only screen and (max-device-width: 480px)"  />
    <link rel='stylesheet' href='./admin/admin.css' type='text/css' />
    <script type='text/javascript' src='./scripts/jquery-1.9.1.min.js' charset='utf-8'></script>
    <script type='text/javascript' src='./bootstrap/js/bootstrap.js' charset='utf-8'></script>
    
    <? echo renderGoogleAnalytics() ?>
    
  </head>
  <body>
    <? renderNavBar("signup") ?>
      
		<div>	
    <?php if( User::isAutentified() ) { ?>
    	<div class="well center" id="register" >
    		<h4>Ya estás registrado.<br> Si deseas crear otro usuario deberás cerrar la sesión.</h4>
    	</div>
    	
		<?php } else { ?>
	
    <form action="new_user.php" class="well form-horizontal center" id="register" method="post">  
	  <h1 class="center-text">
	    Regístrate
	  </h1>
 
  
  <?  
    if($alert != "") {
      echo "
        <div class='alert alert-danger'>
          $alert
        </div>
      ";
    }
  ?>
		<fieldset>
			<div class="control-group">
        <label class="control-label" for="email">Tu email</label>
        <div class="controls">
          <input type="text" class="input-xlarge" name="email" id="email" maxlength="100" placeholder="Email" value="<?echo $email?>">
        </div>
      </div>
			<div class="control-group">
        <label class="control-label" for="nombre">Nombre</label>
        <div class="controls">
          <input type="text" class="input-xlarge" name="nombre" id="nombre" size=28 maxlength="255" placeholder="Nombre" value="<?echo $nombre?>">
        </div>
      </div>
			<div class="control-group">
        <label class="control-label" for="organizacion">Organización</label>
        <div class="controls">
          <input type="text" class="input-xlarge" name="organizacion" id="organizacion" size=28 maxlength="255" placeholder="Organización" value="<?echo $organizacion?>">
        </div>
      </div>
			<div class="control-group">
        <label class="control-label" for="password">Password</label>
        <div class="controls">
          <input type="password" class="input-xlarge" name="password" id="password" size=28 maxlength="255" placeholder="Password">
        </div>
      </div>
			<div class="control-group">
        <label class="control-label" for="repite_password">Repite Password</label>
        <div class="controls">
          <input type="password" class="input-xlarge" name="repite_password" id="repite_password" size=28 maxlength="255" placeholder="Repite Password">
        </div>
      </div>
      
      <div class="control-group">
      	<div class="controls">   
	        <? renderCaptcha(); ?>
         </div>
			</div>
     	<button type="submit" class="btn btn-info">Registrarse</button>
      <a href="index.php" class="btn" data-dismiss="modal" style="float: right;">Cerrar</a>
     </form>
    <?php } ?>
    </div>
</body>
</html>